package com.icedevcloud.upms.controller.admin.tenant;

import com.icedevcloud.common.core.api.R;
import com.icedevcloud.common.core.log.IceLog;
import com.icedevcloud.upms.controller.admin.tenant.dto.AddTenantReqDto;
import com.icedevcloud.upms.controller.admin.tenant.dto.UpdateTenantReqDto;
import com.icedevcloud.upms.service.ISysTenantService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 租户表 前端控制器
 * </p>
 *
 * @author XiaoBingBy
 * @since 2023-08-13
 */
@Tag(name = "租户接口类")
@RequiredArgsConstructor
@RestController
@RequestMapping("/sysTenant")
public class SysTenantController {

    private ISysTenantService iSysTenantService;

    @IceLog
    @Operation(summary = "添加租户接口")
    @PostMapping("/add")
    public R<Boolean> add(@RequestBody @Validated AddTenantReqDto reqDto) {
        Boolean result = iSysTenantService.add(reqDto);
        return R.ok(result);
    }

    @IceLog
    @Operation(summary = "更新租户接口")
    @PutMapping("/update")
    public R<Boolean> update(@RequestBody @Validated UpdateTenantReqDto reqDto) {
        Boolean result = iSysTenantService.update(reqDto);
        return R.ok(result);
    }

    @IceLog
    @Operation(summary = "删除租户接口")
    @DeleteMapping("/delete")
    public R<Boolean> delete(@NotNull(message = "ID不能为空") Long id) {
        Boolean result = iSysTenantService.delete(id);
        return R.ok(result);
    }

}
